<?php

class cacheEdit{

 function cacheEdit($dir,$cat,$article){
   $dh = opendir($dir);
   while ($filename = readdir($dh)){
    if (($filename != '.') && ($filename != '..')){
     if (file_exists($dir.$filename.'/cache')){
      $dh2 = opendir($dir.$filename.'/cache/');
      while ($fn = readdir($dh2)){
        if (is_array($cat)){
          foreach($cat As $c){
            if (preg_match('/cache'.$c.'_\d+_\d+/',$fn)){
              $delfile[] = $dir.$filename.'/cache/'.$fn;
            }
          }
        }
        if (is_array($article)){
          foreach($article As $a){
            if (preg_match('/cache\d+_\d+_'.$a.'$/',$fn)){
              $delfile[] = $dir.$filename.'/cache/'.$fn;
            }
          }
        }
        if (is_array($delfile)){
          foreach($delfile As $df){
            if (file_exists($df))
              unlink($df);
          }
          unset($delfile);
        }
      }
     } # file_exists cachedir
    } # filename
   } # while
 }

}

?>